package com.sq.partner.manager.service;

import java.io.InputStream;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpSession;

import org.springframework.web.multipart.MultipartFile;

import com.sq.partner.manager.common.Result;
import com.sq.partner.manager.common.exception.AppException;
import com.sq.partner.manager.mybatis.model.DictAddrDto;
import com.sq.partner.manager.mybatis.model.DictDto;
import com.sq.partner.manager.mybatis.model.GatewayAppTranstype;
import com.sq.partner.manager.mybatis.model.GatewayChannelDemandConfig;
import com.sq.partner.manager.mybatis.model.GatewayChannelInfo;
import com.sq.partner.manager.mybatis.model.GatewayChannelIp;
import com.sq.partner.manager.mybatis.model.GatewayChannelTranstype;
import com.sq.partner.manager.mybatis.model.GatewayChannelUser;
import com.sq.partner.manager.mybatis.model.GatewayUser;
import com.sq.partner.manager.mybatis.model.NlifePlan;
import com.sq.partner.manager.mybatis.model.TradInsuPlan;
import com.sq.partner.manager.mybatis.model.TreeDto;
import com.sq.partner.manager.util.Page;

/**
 * 
 * @author duguangwei
 *
 */

public interface IGatewayChannelInfoConfigService {
	public Page getListByAppid(String appId)throws Exception;
	public Page<GatewayChannelInfo> getListByDept(Page<GatewayChannelInfo> page)throws Exception;
	
	public Page getList(Page page)throws Exception;
	public Page getTranstypeBychannelCode(String channel_Code,String appid,String application)throws Exception;
	public Page loadTransNameByApplication(String appid,String channel_Code)throws Exception;
	public Page loadTransNameByApplication1(String appid)throws Exception;

	/**
	 * 分页条件查询ChannelInfo
	 * @param pageIndex
	 * @param channelInfo
	 * @return
	 */
	public Page queryByCriteria(Integer pageIndex,GatewayChannelInfo channelInfo, GatewayUser user) throws Exception;
	/**
	 * 根据channelCode删除相应ChannelInfo
	 * @param channelInfo
	 */
	public Result deleteChannelInfoByChannelCode(GatewayChannelInfo channelInfo) throws Exception;
	/**
	 * 更改ChannelInfo的fkAppId
	 * @param channelInfo
	 */
	public void updateChannelAppId(GatewayChannelInfo channelInfo) throws Exception;
	
	/**
	 * 添加/更新channelInfo
	 * @param channelInfo
	 * @throws Exception
	 */
	public void saveOrUpdateChannelInfo(GatewayChannelInfo channelInfo,String flag) throws Exception;
	
	/**
	 * 根据channelCode查询相应的channelInfo
	 * @param channelCode
	 * @return
	 * @throws Exception
	 */
	public GatewayChannelInfo queryChannelInfoByChannelCode(String channelCode) throws Exception;
	
	/**
	 * 根据fkChannelCode查询相应的ChannelUser
	 * @param fkChannelCode
	 * @return List<GatewayChannelUser>
	 * @throws Exception
	 */
	public List<GatewayChannelUser> queryChannelUserByFkChannelCode(String fkChannelCode,String appid) throws Exception;
	
	/**
	 * 根据channelUser属性查询相应的channelUser(返回一个channelUser对象)
	 * @param channelUser
	 * @return GatewayChannelUser
	 * @throws Exception
	 */
	public GatewayChannelUser queryChannelUserByChannelUser(GatewayChannelUser channelUser) throws Exception;
	
	/**
	 * 根据channelUser属性删除相应的channelUser
	 * @param channelUser
	 * @throws Exception
	 */
	public void delChannelUserByChannelUser(GatewayChannelUser channelUser) throws Exception;
	
	/**
	 * 添加channelUser
	 * @param channelUser
	 * @throws Exception
	 */
	public void saveChannelUser (GatewayChannelUser channelUser) throws Exception;
	
	/**
	 * 根据channelIp属性查询相应的channelIp
	 * @param gatewayChannelIp
	 * @return
	 * @throws Exception
	 */
	public List<GatewayChannelIp> queryChannelIpByChannelIp(GatewayChannelIp channelIp) throws Exception;
	
	/**
	 * 根据channelIp属性删除相应的channelIp
	 * @param channelIp
	 * @throws Exception
	 */
	public void delChannelIpByChannelIp(GatewayChannelIp channelIp) throws Exception;
	
	/**
	 * 添加channelIp
	 * @param channelIp
	 * @throws Exception
	 */
	public void saveChannelIp(GatewayChannelIp channelIp) throws Exception;
	
	/**
	 * 根据channelTranstype属性查询相应的channelTranstype
	 * @param channelTranstype
	 * @return List<GatewayChannelTranstype>
	 * @throws Exception
	 */
	public List<GatewayChannelTranstype> queryChannelTranstypeByChannelTranstype(GatewayChannelTranstype channelTranstype) throws Exception;
	
	/**
	 * 根据channelTranstype属性删除相应的channelTranstype
	 * @param channelTranstype
	 * @throws Exception
	 */
	public void delChannelTranstypeByChannelTranstype(Long transTypeId,String channelCode) throws Exception;
	
	/**
	 * 根据传入的channelCode查询在该channelTranstype中不存在，而在该channelCode所属app中存在的appTranstype
	 * @param channelInfo
	 * @return
	 * @throws Exception
	 */
	public List<GatewayAppTranstype> queryNotUsedAppTranstype(GatewayChannelInfo channelInfo) throws Exception;
	
	/**
	 * 添加channelTranstype
	 * @param channelTranstype
	 * @throws Exception
	 */
	public void saveChannelTranstype (GatewayChannelTranstype channelTranstype) throws Exception;

	/**
	 * 获取传入用户的权限机构及其分机构（分公司-- deptCode.length()==2 ）
	 * @param user
	 * @return
	 * @throws Exception
	 */
	public List<TreeDto> queryBranchDeptOfOneUser(GatewayUser user) throws Exception;
	/**
	 * 获取省市县三级数据的下拉框
	 * @param areaCode,parentCode
	 * @return
	 * @throws Exception
	 */
	//查询省市县三级联动接口
	public List<DictAddrDto> queryProvinceCityCounty(DictAddrDto dictAddr) throws Exception;
	//查询企业类型和行业类型二级联动接口
	public List<DictDto> querySubElementList(DictDto dict) throws Exception;
	
	public void delTransTypeByChannelCodeAndAppId(GatewayChannelTranstype gct) throws Exception;
	
	public Page queryAppInfoByChannelCode(Integer pageIndex, String channelCode) throws Exception;
	
	public  boolean checkIsHasPrivilege(HttpSession session,String deptCode) throws Exception;
	
	public void clearAllCacheByChannelCode(String channelCode) throws Exception;
	
	public void clearAllCacheByChannelCodeExtend(List<TradInsuPlan> tradInsuPlanLists) throws Exception;
	
	public void clearAllNewLifeCacheByChannelCodeExtend(List<NlifePlan> tradInsuPlanLists) throws Exception;

	public Page<GatewayChannelInfo> getChannelInfoListByDeptCode(Page<GatewayChannelInfo> page)throws Exception;
	
	/**
	 * 查询传入的合作伙伴的合作伙伴子机构
	 * @param parentChannelCode
	 * @return
	 * @throws Exception
	 */
	public List<TreeDto> querySubChannelTreeByParentChannelCode(String parentChannelCode) throws Exception;
	
	public Page<GatewayChannelDemandConfig> queryDemandList(Page<GatewayChannelDemandConfig> page)throws Exception;
	
	public String insertChannelDemands(List<GatewayChannelDemandConfig> list) throws Exception;
	
	public String insertVersion(GatewayChannelDemandConfig gatewayChannelDemandConfig);
	
	public GatewayChannelDemandConfig queryDemandForUpdate(Map<String, Object> map) throws Exception;
	
	public boolean updateChannelDemand(GatewayChannelDemandConfig info)throws Exception;
	
	public String insertDemandCost(GatewayChannelDemandConfig config);
	
	public List<GatewayChannelDemandConfig> selectDemandList(Map<String,Object>map)throws Exception;
	
	public List<InputStream> getFileInputStream(MultipartFile[] myfiles) throws AppException;

	public void importExcelForDemand(InputStream inputStream,GatewayUser user,HttpSession session,List<String> list) throws Exception;
	
	public List<GatewayChannelDemandConfig> selectPartnerInfo(GatewayChannelDemandConfig info) throws Exception;
	
	public List<GatewayChannelDemandConfig> selectVersionInfo(GatewayChannelDemandConfig info) throws Exception;
	
	public List<GatewayChannelDemandConfig> selectDemandInfo(GatewayChannelDemandConfig info) throws Exception;
	
	public boolean deleteChannelCosts(Map<String,Object>map)throws Exception;
	
	public boolean deleteChannelDemands(Map<String,Object>map)throws Exception;
	
	public List<GatewayChannelDemandConfig> demandExportSelect(Map<String,Object>map)throws Exception;
	
	public boolean updateDemandCost(GatewayChannelDemandConfig info)throws Exception;
	
	public int queryVersionExist(String channelVersion)throws Exception;
	
	public List<String> queryDemandChannelCode(Map<String,Object>map)throws Exception;
	public void saveOrUpdateChannelInfoToURL(GatewayChannelInfo channelInfo, String flag) throws Exception;
	public Page<Map<String, Object>> queryByCriteria1(Integer pageIndex, Integer size,GatewayChannelInfo channelInfo, GatewayUser user,String businessChannelType) throws Exception;

	/**查询意健险方案是否为互联网业务方案*/
	String queryIfInternetPlan(String partnerCode) throws Exception;
}
